//
//  LCAccountManager.m
//  JK登录注册
//
//  Created by jiukuyinyue on 2017/8/12.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCAccountManager.h"
#import "NSString+MD5.h"
#import "UserInfo.h"



@implementation LCAccountManager

IMPLEMENTATION_SINGLETON(LCAccountManager)


-(void)setUseruid:(NSInteger)useruid{
    [[NSUserDefaults standardUserDefaults] setInteger:useruid forKey:USERUID];
}

-(NSInteger)useruid{
    NSInteger uid = [[NSUserDefaults standardUserDefaults] integerForKey:USERUID];
    return uid;
}

-(void)setUserName:(NSString *)userName{
    [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"USERNAME"];
}

-(NSString *)userName{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"USERNAME"];
}

-(void)setUserPicUrl:(NSString *)userPicUrl{
    [[NSUserDefaults standardUserDefaults] setObject:userPicUrl forKey:@"USERPICURL"];
}

-(NSString *)userPicUrl{
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"USERPICURL"];
}
///用于游戏大厅跳转拼接
- (NSString *)getUrlStr:(NSString *)UrlStr{
    NSString *key = @"#k14kl12m4,m,1l2486*Y&*YJkj";

    NSDate *dat = [NSDate dateWithTimeIntervalSinceNow:0];
    NSTimeInterval a = [dat timeIntervalSince1970];
    NSString *timeString = [NSString stringWithFormat:@"%.0f", a * 1000];
//    NSLog(@"%@", timeString);
    NSInteger uid = self.useruid;//self.useruid;//83908;
//    NSLog(@"%ld", (long)uid);
    NSString *sign = [[NSString stringWithFormat:@"uid=%zd&time=%@%@",uid,timeString,key] md5];
    return [NSString stringWithFormat:@"%@?uid=%zd&time=%@&sign=%@",UrlStr,uid,timeString,sign];
}
///用于Game跳转拼接
- (NSString *)getUrlStr2:(NSString *)UrlStr{
    NSString *key = @"#k14kl12m4,m,1l2486*Y&*YJkj";
    
    NSDate *dat = [NSDate dateWithTimeIntervalSinceNow:0];
    NSTimeInterval a = [dat timeIntervalSince1970];
    NSString *timeString = [NSString stringWithFormat:@"%.0f", a * 1000];
    //    NSLog(@"%@", timeString);
    NSInteger uid = self.useruid;//self.useruid;//83908;
//    NSLog(@"%ld", (long)uid);
    NSString *sign = [[NSString stringWithFormat:@"uid=%zd&time=%@%@",uid,timeString,key] md5];
    return [NSString stringWithFormat:@"%@&uid=%zd&time=%@&sign=%@",UrlStr,uid,timeString,sign];
}

@end
